var fs = require('fs')
var path = require('path')
var _ = require('lodash')

var env = _.indexOf(['demo', 'pro', 'test'], process.env.NODE_ENV) === -1
    ? 'dev' : process.env.NODE_ENV

var config = {env}

var _config = fs.readdirSync(path.join(__dirname, env))
  .reduce((_config, filename) => {
    var key = filename.replace(/[.]/g, '_').replace(/_js$/, '')
    _config[key] = require(path.join(__dirname, env, filename))
    return _config
  }, {})

config = _.extend(config, _config)
module.exports = config
